package com.pks.datacenter.entity.api;

import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;

import com.pks.util.coder.database.DBField;
import com.pks.util.coder.database.DBQuery;
import com.pks.util.coder.database.DBTable;
import com.pks.web.mybatis.entity.BasicEntity;

@Data
@EqualsAndHashCode(callSuper = true)
@DBTable(tags = "数据源对外接口" , index_normal = {"dbId,type"},index_unique="methodName")
public class ApiMethod extends BasicEntity{
	
	
	private static final long serialVersionUID = -5876842571440830142L;

	
	public static final int TYPE_HTTP = 1;
	
	@DBQuery(value = {"=" })
	@DBField(name = "tagId" , comment = "所属标签" )
	private Long tagId ; 			
	
	@DBField(comment = "数据源ID" , nullable = false)
	@DBQuery
	private Long dbId;
	
	@DBField(comment = "接口类型 1-HTTP/HTTPS接口（暂时只做这个） ")
	@DBQuery
	private Integer type;
	
	@DBField(comment = "接口名称")
	@DBQuery(value = {"=" , "like"})
	private String apiName;
	
	@DBField(comment = "接口方法名，将直接拼接在固定接口地址中  如aaa 即为  xxx/aaa")
	@DBQuery(value = {"=" , "like"})
	private String methodName;
	
	@DBField(comment = "排序号")
	private Long orders;
	
	@DBField(comment = "固定查询条件")  
	private String whereSql;
	
	@DBField(comment = "查询列表数量(为空时默认100)" ,defaultValue = "100")
	private Long selectSize;
	
	@DBField(comment = "每天调用次数  null/0 - 不限制")
	private Long dayCount;
	
	@DBField(comment = "调用最小频率（秒）")
	private Long intervalTime;
	
	@DBQuery
	@DBField(comment = "是否开启  1-是  0-否")
	private Integer state;

	@DBField(comment = "接口描述" , length = 255)
	private String remark;
	
	@DBField(comment = "是否必须设置固定参数" , length = 1)
	private Integer addQuerySqlRequired;

	
	private String show_dbName;
	private List<ApiField> show_apiFieldList;
	private Integer show_apiUserPermState;
	private String show_tagName;
	private Integer show_apiUserSelectPermState;
	
	@Override
	public void insertBefore() {
		super.insertBefore();
		if (type == null) {
			type = 1;
		}
		if (state == null) {
			state = 1;
		}
	}
	
	
}
